%% Analysis of Steady-State 25C vs. 37C BarSeq data from Feb. 18 2021 samples
load('EcoliBW25113_Tn_LB_steadystate_20200303.mat');
temp = Downshifts_Mar3;
close all;

%% Create plotting arrays
time_37to37C = [-10 0 10 20 30 40 60 90];
fitness_array_37to37C = [temp.setAIT06233_37to37_10min_B temp.setAIT06333_37to37_0min_B temp.setAIT06433_37to37_10min_B temp.setAIT06533_37to37_20min_B temp.setAIT06733_37to37_30min_B temp.setAIT06833_37to37_40min_B temp.setAIT06933_37to37_60min_B temp.setAIT07033_37to37_90min_B];

time_37to25C = [-10 10 20 30 40 60 90];
fitness_array_37to25C = [temp.setAIT07133_37to25_10min_B temp.setAIT07333_37to25_10min_B temp.setAIT07433_37to25_20min_B temp.setAIT07533_37to25_30min_B temp.setAIT07633_37to25_40min_B temp.setAIT07733_37to25_60min_B temp.setAIT07833_37to25_90min_B];

%% Plot 25to37C data
hits_37to37C = [];

figure;
for k=1:size(fitness_array_37to37C,1)
    if mean(abs(fitness_array_37to37C(k,:)))<1
        plot(time_37to37C, fitness_array_37to37C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_37to37C, fitness_array_37to37C(k,:), 'r');
        hits_37to37C = [hits_37to37C; k];
        text(time_37to37C(end), fitness_array_37to37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Plot 25to25C data
hits_37to25C = [];

figure;
for k=1:size(fitness_array_37to25C,1)
    if mean(abs(fitness_array_37to25C(k,:)))<1
        plot(time_37to25C, fitness_array_37to25C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_37to25C, fitness_array_37to25C(k,:), 'b');
        hits_37to25C = [hits_37to25C; k];
        text(time_37to25C(end), fitness_array_37to25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Display hits
disp('37 to 37 hits');
temp.genename(hits_37to37C)
disp('37 to 25 hitsL');
temp.genename(hits_37to25C)